/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controlador;

import Modelo.Listas;
import Modelo.Rutas;
import Vista.JFrameRutas;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;


public class ControladorRutas implements ActionListener,KeyListener
{
    private JFrameRutas formRutas;
    private Listas listaRutas;

    public ControladorRutas(Listas ListaR) 
    {
        listaRutas = ListaR;
        formRutas = new JFrameRutas();
        formRutas.agregarListener(this, this);
        formRutas.setVisible(true);
        Enabled(false);
      
       //-------------------
        formRutas.getTxtCodigoR().addKeyListener(new KeyAdapter()
                
                   {        
                        public void keyTyped (KeyEvent e)
                          {     
                            CodigoRKeyTyped(e);  
                          }
                         
                       public void keyPressed(KeyEvent e) 
                       {
                         CodigoRKeyPressed(e);  
                       }      

            private void CodigoRKeyTyped(java.awt.event.KeyEvent evt)
                    
            {
              String Cadena;
                 Cadena=formRutas.getTxtCodigoR().getText();
                 if (Cadena.length()==10)
                 evt.consume();  
                    
             }

            private void CodigoRKeyPressed(KeyEvent e) 
    {
      
    } 
                         
  });
        
    }
//************************************
   
    @Override
    public void keyTyped(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void keyPressed(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void keyReleased(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    private void Enabled(boolean Status) 
    {
        formRutas.getTxtCodigoR().setEnabled(!Status);
        formRutas.getTxtDestinoR().setEnabled(Status);
        formRutas.getCmbEstadoR().setEnabled(Status);
        formRutas.getCmbDescripcionR().setEnabled(Status);
    }
//**********************
    
    
 @Override
    public void actionPerformed(ActionEvent e)
    {
      if (e.getSource().equals(formRutas.getBtnBuscarR()))  
         new ControladorConsulRutas(listaRutas); 
    }
    
}
